home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / fsattach / RCS / fsattach.h,v < prev    next >
Encoding:
Text File  |  1991-01-13  |  8.8 KB  |  436 lines

  1. head     1.7;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.7
  10. date     91.01.12.16.48.54;  author jhh;  state Exp;
  11. branches ;
  12. next     1.6;
  13.  
  14. 1.6
  15. date     90.02.14.13.59.59;  author jhh;  state Exp;
  16. branches ;
  17. next     1.5;
  18.  
  19. 1.5
  20. date     89.12.14.16.28.23;  author jhh;  state Exp;
  21. branches ;
  22. next     1.4;
  23.  
  24. 1.4
  25. date     89.06.19.14.21.27;  author jhh;  state Exp;
  26. branches ;
  27. next     1.3;
  28.  
  29. 1.3
  30. date     89.06.07.22.14.35;  author jhh;  state Exp;
  31. branches ;
  32. next     1.2;
  33.  
  34. 1.2
  35. date     89.04.10.11.12.25;  author jhh;  state Exp;
  36. branches ;
  37. next     1.1;
  38.  
  39. 1.1
  40. date     89.03.06.12.58.47;  author jhh;  state Exp;
  41. branches ;
  42. next     ;
  43.  
  44.  
  45. desc
  46. @@
  47.  
  48.  
  49. 1.7
  50. log
  51. @new boot sequence
  52. @
  53. text
  54. @/*
  55.  * fsattach.h --
  56.  *
  57.  *    Declarations for fsattach.
  58.  *
  59.  * Copyright 1989 Regents of the University of California
  60.  * Permission to use, copy, modify, and distribute this
  61.  * software and its documentation for any purpose and without
  62.  * fee is hereby granted, provided that the above copyright
  63.  * notice appear in all copies.  The University of California
  64.  * makes no representations about the suitability of this
  65.  * software for any purpose.  It is provided "as is" without
  66.  * express or implied warranty.
  67.  *
  68.  * $Header: /sprite/src/admin/fsattach/RCS/fsattach.h,v 1.6 90/02/14 13:59:59 jhh Exp $ SPRITE (Berkeley)
  69.  */
  70.  
  71. #ifndef _FSATTACH
  72. #define _FSATTACH
  73.  
  74. #include <assert.h>
  75. #include <errno.h>
  76. #include <fs.h>
  77. #include <fsCmd.h>
  78. #include <host.h>
  79. #include <list.h>
  80. #include <option.h>
  81. #include <stdio.h>
  82. #include <string.h>
  83. #include <status.h>
  84. #include <stdlib.h>
  85. #include <sysStats.h>
  86. #include <sys/types.h>
  87. #include <sys/stat.h>
  88. #include <sys/file.h>
  89. #include <sys/wait.h>
  90. #include <disk.h>
  91.  
  92. /* constants */
  93.  
  94. /*
  95.  * Maximum limits on things.
  96.  */
  97. #define MAX_FIELD_LENGTH    256
  98. #define MAX_LINE_LENGTH        1024
  99. #define MAX_EXEC_ARGS        20
  100. #define MAX_PASS         10
  101.  
  102. /*
  103.  * Return codes from fscheck.
  104.  */
  105. #define FSCHECK_OK        (char) 0
  106. #define FSCHECK_SOFT_ERROR    (char) 1
  107. #define FSCHECK_OUT_OF_MEMORY    (char) 2
  108. #define FSCHECK_NOREBOOT    (char) 3
  109. #define FSCHECK_REBOOT        (char) 4
  110.  
  111. #define FSCHECK_HARD_ERROR    (char) -1
  112. #define FSCHECK_READ_FAILURE    (char) -2
  113. #define FSCHECK_WRITE_FAILURE    (char) -3
  114. #define FSCHECK_BAD_ARG        (char) -4
  115. #define FSCHECK_MORE_MEMORY    (char) -5
  116. #define FSCHECK_DISK_FULL    (char) -6
  117.  
  118. /*
  119.  * Return code from child process if the exec fails.
  120.  */
  121. #define EXEC_FAILED        (char) 32
  122.  
  123. /* 
  124.  * Exit codes.
  125.  */
  126. #define OK         0
  127. #define REBOOT        1
  128. #define HARDERROR     2
  129. #define SOFTERROR    3
  130. #define NOREBOOT    4
  131.  
  132. /* 
  133.  * Status of entry in mount table. Starts off as CHILD_OK, changes to 
  134.  * CHILD_RUNNING while fscheck is running. If fscheck completes ok, 
  135.  * then status changes back to CHILD_OK to indicate that the prefix should 
  136.  * be attached. Otherwise the status changes to CHILD_FAILURE.
  137.  */
  138. #define CHILD_OK    0
  139. #define CHILD_RUNNING    1
  140. #define CHILD_FAILURE    2
  141.  
  142.  
  143. /* data structures */
  144.  
  145.  
  146. /*
  147.  * Information stored about active child processes.
  148.  */
  149. typedef struct {
  150.     int        pid;        /* process id of child */
  151.     int        mountIndex;    /* index in mount table that child corresponds
  152.                  * to */
  153. } ChildInfo;
  154.  
  155. /*
  156.  * Used to build a linked list of arguments.
  157.  */
  158. typedef struct {
  159.     List_Links    links;        /* Used to make a list */
  160.     char    *arg;        /* Ptr to argument string */
  161. } ArgHeader;
  162.  
  163.  
  164. /*
  165.  * Information about arguments to fscheck. We build up a table of these
  166.  * for devices we haven't seen yet in the mount table. This allows "Arg"
  167.  * commands for a device to precede the "Attach" or "Export" command.
  168.  * Also arguments for "all" devices are kept in the table until the
  169.  * entire mount file is parsed.
  170.  */
  171. typedef struct {
  172.     char    source[MAX_FIELD_LENGTH];     /* name of device arguments
  173.                          * are for */
  174.     int        line;                /* line number of "args" cmd */
  175.     ArgHeader    argList;            /* list of arguments */
  176. } ArgInfo;
  177.  
  178. /* 
  179.  * Entry in the mount table.
  180.  */
  181. typedef struct {
  182.     char    source[MAX_FIELD_LENGTH];    /* name of source device or
  183.                          * prefix */
  184.     char     dest[MAX_FIELD_LENGTH];        /* name of destination prefix */
  185.     int        group;                /* check group of device */
  186.     Boolean    device;                /* TRUE => source is a device */
  187.     Boolean    export;                /* TRUE => export prefix */
  188.     Boolean    readonly;            /* TRUE => prefix should be
  189.                          * mounted as read only */
  190.     Boolean    doCheck;            /* device should be checked */
  191.     int        status;                /* status of this entry */
  192.     ArgInfo    argInfo;            /* arguments to fscheck */
  193.     Boolean    checked;            /* TRUE => fscheck was run */
  194. } MountInfo;
  195.  
  196. /*
  197.  * Used to store information about groups (disks that cannot be checked
  198.  * at the same time.
  199.  */
  200.  
  201. typedef struct {
  202.     char    name[MAX_FIELD_LENGTH];        /* name of group */
  203.     Boolean    running;            /* is there an fscheck
  204.                          * running for a device in
  205.                          * in this group? */
  206. } GroupInfo;
  207.  
  208. /*
  209.  * Used to allocate memory.
  210.  */
  211. #define Alloc(ptr,type, number, msg) { \
  212.     (ptr) = (type *) malloc((unsigned) (sizeof(type) * (number))); \
  213.     if ((ptr) == NULL) { \
  214.         (void) fprintf(stderr, "Out of memory: %s.\n",msg); \
  215.         (void) exit(HARDERROR); \
  216.     } \
  217.     }
  218.  
  219. /* 
  220.  * Handy comparison macros.
  221.  */
  222. #define min(a,b) (((a) < (b)) ? (a) : (b) )
  223. #define max(a,b) (((a) > (b)) ? (a) : (b) )
  224.  
  225. /*
  226.  * Global variables.
  227.  */
  228. extern char        *progName;
  229. extern int        mountTableSize;
  230. extern int        mountTableSizeIncrement;
  231. extern char        *tempOutputFile;
  232. extern char        *heapLimitString;
  233. extern int        tempOutputFileSize;
  234. extern char        *outputDir;
  235. extern Boolean        verbose;
  236. extern MountInfo    *mountTable;
  237. extern Boolean        printOnly;
  238. extern char        *fscheckPath;
  239. extern char        *bootPrefix;
  240. extern int        numGroups;
  241. extern GroupInfo    *groupInfo;
  242. extern int        groupInfoSize;
  243. extern int        groupInfoSizeIncrement;
  244. extern int        debug;
  245.  
  246. /*
  247.  * Global functions.
  248.  */
  249. extern    void        GetRecoveryInfo();
  250. extern    ReturnStatus    ParseMount();
  251. extern    ReturnStatus    CheckDisks();
  252. extern    void        CacheWriteBack();
  253. extern    ReturnStatus    RunChild();
  254. extern    void        StartExec();
  255. extern    void        AddExecArgs();
  256. extern    int        DoExec();
  257. extern    void        MoveRootOutput();
  258. extern    ReturnStatus    ParseConfig();
  259. extern  void        Prefix();
  260. extern  void        PrintFscheckError();
  261. extern    void        AddList();
  262. extern    void        MergeList();
  263. extern    void        DeleteList();
  264. extern  void        PreloadPrefixTable();
  265. extern    char        *GetAttachName();
  266. extern void        bzero();
  267. extern int        exit();
  268.  
  269. #endif /* _FSATTACH */
  270.  
  271. @
  272.  
  273.  
  274. 1.6
  275. log
  276. @Uses groups instead of passes
  277. @
  278. text
  279. @d15 1
  280. a15 1
  281.  * $Header: /sprite/src/admin/fsattach/RCS/fsattach.h,v 1.5 89/12/14 16:28:23 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  282. d37 1
  283. a37 1
  284. #include <diskUtils.h>
  285. d56 1
  286. d140 1
  287. d178 1
  288. a178 1
  289. extern char        *rootTempOutputFile;
  290. d180 1
  291. a180 1
  292. extern int        rootTempOutputFileSize;
  293. d191 1
  294. d212 1
  295. a212 1
  296.  
  297. @
  298.  
  299.  
  300. 1.5
  301. log
  302. @was opening /.fscheck.out, which is the wrong file on fileservers
  303. that do not boot standalone.  Now opens /bootTmp/.fscheck.out
  304. @
  305. text
  306. @d15 1
  307. a15 1
  308.  * $Header: /sprite/src/admin/fsattach/RCS/fsattach.h,v 1.4 89/06/19 14:21:27 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  309. d131 1
  310. a131 2
  311.     int        pass;                /* pass on which to check
  312.                          * device */
  313. d142 12
  314. a180 1
  315. extern int        maxPass;
  316. a181 1
  317. extern int        *partsToDo;
  318. d185 4
  319. @
  320.  
  321.  
  322. 1.4
  323. log
  324. @Added stuff to preload prefix table
  325. @
  326. text
  327. @d15 1
  328. a15 1
  329.  * $Header: /sprite/src/admin/fsattach/RCS/fsattach.h,v 1.3 89/06/07 22:14:35 jhh Exp $ SPRITE (Berkeley)
  330. d175 1
  331. @
  332.  
  333.  
  334. 1.3
  335. log
  336. @Spring cleaning - new mount table format, bug fixes
  337. @
  338. text
  339. @d15 1
  340. a15 1
  341.  * $Header: /sprite/src/admin/fsattach/RCS/fsattach.h,v 1.2 89/04/10 11:12:25 jhh Exp $ SPRITE (Berkeley)
  342. d194 1
  343. @
  344.  
  345.  
  346. 1.2
  347. log
  348. @First working version
  349. @
  350. text
  351. @d15 1
  352. a15 1
  353.  * $Header: /sprite/users/jhh/fsattach/RCS/fsattach.h,v 1.1 89/03/06 12:58:47 jhh Exp Locker: jhh $ SPRITE (Berkeley)
  354. d26 1
  355. a49 10
  356.  * Default values for variables that can be modified in configuration file.
  357.  */
  358. #define DEFAULT_MAX_MOUNT_ENTRIES     30
  359. #define DEFAULT_ROOT_TEMP_NAME         ".fscheck.out"
  360. #define DEFAULT_OUTPUT_DIR         "/local"
  361. #define DEFAULT_HEAP_LIMIT        "1000000"
  362. #define DEFAULT_ROOT_TEMP_SIZE         8192
  363. #define DEFAULT_FSCHECK_PATH        "fscheck"
  364.  
  365. /*
  366. d91 33
  367. d139 1
  368. a142 10
  369.  * Information stored about active child processes.
  370.  */
  371. typedef struct {
  372.     int        pid;        /* process id of child */
  373.     int        mountIndex;    /* index in mount table that child corresponds
  374.                  * to */
  375. } ChildInfo;
  376.  
  377.  
  378. /*
  379. d164 1
  380. d191 3
  381. @
  382.  
  383.  
  384. 1.1
  385. log
  386. @Initial revision
  387. @
  388. text
  389. @d15 1
  390. a15 1
  391.  * $Header: /sprite/lib/forms/RCS/proto.h,v 1.2 89/01/07 04:12:44 rab Exp $ SPRITE (Berkeley)
  392. d40 3
  393. d48 3
  394. d56 9
  395. d66 6
  396. a71 3
  397. #define FSCHECK_OK        0
  398. #define FSCHECK_SOFT_ERROR    1
  399. #define FSCHECK_OUT_OF_MEMORY    2
  400. d73 4
  401. a76 6
  402. #define FSCHECK_HARD_ERROR    -1
  403. #define FSCHECK_READ_FAILURE    -2
  404. #define FSCHECK_WRITE_FAILURE    -3
  405. #define FSCHECK_BAD_ARG        -4
  406. #define FSCHECK_MORE_MEMORY    -5
  407. #define FSCHECK_DISK_FULL    -6
  408. d78 3
  409. d85 11
  410. d97 1
  411. d100 3
  412. d104 11
  413. a114 9
  414.     char    source[MAX_FIELD_LENGTH];
  415.     char     dest[MAX_FIELD_LENGTH];
  416.     int        pass;
  417.     Boolean    device;
  418.     Boolean    export;
  419.     Boolean    root;
  420.     Boolean    readonly;
  421.     Boolean    doCheck;
  422.     int        status;
  423. d117 3
  424. d121 3
  425. a123 2
  426.     int        pid;
  427.     int        mountIndex;
  428. d127 3
  429. d138 3
  430. d144 3
  431. d158 1
  432. d160 3
  433. a162 1
  434.  
  435. @
  436.